package cn.sdstudio.config;

import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * @author zyq
 */
@Getter
public class CustomUserDetails extends User {

    private final Long id;

    /**
     * 存储权限信息
     */
    private final List<String> permissionString;


    public CustomUserDetails(Long id, String username, String password,
                             boolean enabled, boolean accountNonExpired,
                             boolean credentialsNonExpired, boolean accountNonLocked,
                             Collection<? extends GrantedAuthority> authorities,
                             List<String> rawPermissionStrings) {
        super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
        this.id = id;
        this.permissionString = (rawPermissionStrings != null) ? List.copyOf(rawPermissionStrings) : Collections.emptyList();
    }


}
